package com.pernix.authen.net;

import com.pernix.authen.MSChapAuthen;
import com.pernix.authen.model.AuthenResult;
import com.pernix.authen.ui.LogOnDialog;
import com.pernix.log.ConsoleLogging;
import java.awt.Frame;

public class ClientThread extends Thread {
	private LogOnDialog dialog;
	private Frame frame;
	private boolean result;
	public ClientThread(LogOnDialog dialog, Frame frame) {
		this.dialog = dialog;
		this.frame = frame;
	}
	public void run() {
		AuthenResult result = MSChapAuthen.Authen(dialog, null);
		if(result.isAuthenSuccess()){
			System.out.println("authen ok");
			//Set ErrorMessage
			//dialog.setErrorMessage(String.format("Cannot Connect to Server %s:%s", result.getServerName(), result.getPort()));
			//Close LogOnDialog
			dialog.dispose();
			frame.show();
			this.result = true;
			System.out.println("show");
		}else{
			dialog.setErrorMessage("Authentication Fail.");
		}
	}
	public boolean isResult() {
		return result;
	}
	public void setResult(boolean result) {
		this.result = result;
	}
}
